/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package knowledgebase.dao;

import knowledgebase.model.User;
import org.hibernate.SessionFactory;
import org.springframework.orm.hibernate3.HibernateTemplate;

/**
 *
 * @author eugene
 */
public class AuthenticationDAOImpl implements AuthenticationDAO {

    private HibernateTemplate hibernateTemplate;
    
    public void setSessionFactory(SessionFactory sessionFactory) {
        hibernateTemplate = new HibernateTemplate(sessionFactory);
    }
    
    @Override
    public User findUserByName(String name) {
        return (User) hibernateTemplate.findByNamedParam("from User where name like :name and enabled = true", "name", name).get(0);
    }
    
}
